package furns.dao.impl;

import furns.dao.BasicDAO;
import furns.dao.OrderItemDAO;
import furns.entity.OrderItem;

import java.util.List;

public class OrderItemDAOImpl extends BasicDAO<OrderItem> implements OrderItemDAO {
    @Override
    public int saveOrderItem(OrderItem orderItem) {
        String sql = "insert into `order_item` (`id`,`name`,`price`,`count`,`total_price`,`order_id`) values(?,?,?,?,?,?)";
        return update(sql, orderItem.getId(), orderItem.getName(), orderItem.getPrice(),
                        orderItem.getCount(), orderItem.getTotalPrice(), orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItemByOrderId(String orderId) {
        String sql = "select `id`,`name`,`price`,`count`,`total_price`,`order_id` from `order_item` where `order_id` = ?";
        return queryMulti(sql, OrderItem.class, orderId);
    }
}
